#!/usr/bin/python

"""
Initializtion
make dir on ftp
0-9, A-Z
"""

from get_kg import do_lftp_script
from kgconfig import *
import os.path
import traceback

def make_init_ftp_script():
	fp = open( os.path.join( WORK_DIR, 'init_ftp_script' ), 'w' )
	CHAR = "0123456789QWERTYUIOPLKJHGFDSAZXCVBNM"
	lftp_bookmark = "bookmark add C3 %s/\n" % FTP_C3
	lftp_open = "o C3\n"
	lftp_cd_kg_archive = "cd %s\n" % KG_ARCHIVE
	fp.write( lftp_bookmark )
	fp.write( lftp_open )
	fp.write( lftp_cd_kg_archive )
	for x in CHAR:
		fp.write( "mkdir %s\n" % x )
	fp.write( "quit\n" )
	fp.flush()
	fp.close()
				
def main():
	make_init_ftp_script()
	do_lftp_script( 'init_ftp_script' )

if __name__ == '__main__':
    try:
	main()
    except:
        f = open( 'Error.log', 'a' )
        traceback.print_exc( file=f )
        f.flush()
        f.close()
															
